<include file="Core:Public:header" />
{:W('Navigation')}
<div class="body-right">
	<div class="row-table">
		<div class="row-table-title">添加岗位</div>
		<div class="row-table-body">
			<form class="form-horizontal " action="{:U('hrm/structure/addposition')}" method="post">
				<p class="form-title">
				<a class="pull-right btn btn-primary btn-xs" href="{:U('hrm/structure/position')}">岗位列表</a>
				添加岗位</p>
				<div class="form-group">
					<label for="name" class="col-sm-2 control-label">岗位名称</label>
					<div class="col-sm-3">
						<input id="name" class="form-control" type="text" name="name" value="">
					</div>
				</div>
				<div class="form-group">
					<label for="name" class="col-sm-2 control-label">所属部门</label>
					<div class="col-sm-3">
						<select name="department_id" class="form-control" onchange="changeRoleContent(this.value)">
						<option value="">请选择所属部门</option>
						<volist name="department_list" id="vo">
							<option value="{$vo.department_id}">{$vo.name}</option>
						</volist>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label for="name" class="col-sm-2 control-label">上级岗位</label>
					<div class="col-sm-3">
						<select name="parent_id" id="parent_id" class="form-control">
						<option value="">请选择上级岗位</option>
						<volist name="position_list" id="vo">
							<option value="{$vo.position_id}">{$vo.name}</option>
						</volist>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label for="name" class="col-sm-2 control-label">编制人数</label>
					<div class="col-sm-3">
						<input id="name" class="form-control" type="text" name="plan_num" value="">
					</div>
				</div>
				<div class="form-group">
					<label for="name" class="col-sm-2 control-label">在编人数</label>
					<div class="col-sm-3">
						<input id="name" class="form-control" type="text" name="real_num" value="">
					</div>
				</div>
				<div class="form-group">
					<label for="name" class="col-sm-2 control-label">岗位描述</label>
					<div class="col-sm-3">
						<input id="description" class="form-control" type="text" name="description" value="">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label"></label>
					<div class="col-sm-3">
						<input name="submit" class="btn btn-primary" type="submit" value="保存"/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="btn" value="取消" onclick="javascript:history.go(-1);"/>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
<div class="clear"></div>
<script type="text/javascript">
function changeRoleContent(department_id){
		if(department_id == ''){
			$("#parent_id").html('<option value="">请选择上级岗位</option>');
		}else{
			$.ajax({
				type:'get',
				url:'{:U("hrm/structure/getPositionDepartment","id=")}'+department_id,
				async:false,
				success:function(data){
					if(data){
						options = '<option value="">请选择上级岗位</option>';
						$.each(data, function(k, v){
							options += '<option value="'+v.position_id+'">'+v.name+'</option>';
						});
						$("#parent_id").html(options);
					}else{
						$("#parent_id").html('<option value="">请选择上级岗位</option>');
					}
				},
				dataType:'json'
			});		
		}
	}
</script>
<include file="Core:Public:alert" />
<include file="Core:Public:footer" />